﻿<!DOCTYPE html>
<html lang="en-us">

<head>
    <title>送检单收发</title>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="icon" href="favicon.ico" />
    <link href="css/bootstrap.min.css" rel="stylesheet" />
    <link href="css/font-awesome.min.css" rel="stylesheet" />
    <link href="css/default.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery.min.js"></script>
    <!-- table导出成csv -->
    <script src="js/bootstrap/bootstrap.min.js"></script>
    <script src="js/bootstrap/bootstrap-table.min.js"></script>
    <script src="js/bootstrap/bootstrap-table-zh-CN.min.js"></script>
    <!--[if lt IE 9]>
      <script src="js/bootstrap/html5shiv.min.js"></script>
      <script src="js/bootstrap/respond.min.js"></script>
    <![endif]-->
    <!--页面加载进度条-->
    <link href="css/pace/dataurl.css" rel="stylesheet" />
    <script src="js/pace/pace.min.js"></script>
    <script src="js/jquery.scrolltopcontrol/scrolltopcontrol.js" type="text/javascript"></script>
    <script src="js/jquery.extend.js" type="text/javascript"></script>
    <script src="js/default.js" type="text/javascript"></script>
    <script src="js/jqueryrotate.js" type="text/javascript"></script>
    <style>
        html,
        body {
            width: 100%;
            height: 100%;
        }

        .fixed-table-header {
            display: none !important;
        }

        .bootstrap-table {
            padding: 10px 16px;
        }

        .agree-item {
            color: #a94442;
        }

        .params-warpper {
            display: flex;
            flex-direction: row;
            padding-right: 200px;
        }

        #search-btn {
            position: absolute;
            right: 50px;
            top: 50%;
            transform: translateY(-50%);
            width: 100px;
        }

        .params-warpper .params-item {
            flex: 1;
            display: flex;
            flex-direction: row;
            margin-top: 10px;
        }

        .params-warpper .params-item label {
            display: inline-block;
            min-width: 120px;
            line-height: 34px;
            text-align: right;
            letter-spacing: 2px;
        }

        .params-warpper .params-item .value {
            flex: 1;
        }

        .maincontent {
            min-width: 1000px !important;
            overflow: hidden !important;
            overflow-x: scroll !important;
        }

        .link {
            color: #f7a591;
            outline: none;
        }

        .link:hover {
            color: #f7a591;
        }

        .pagination>li>a,
        .pagination>li>span {
            color: #f7a591;
        }

        .pagination>.active>a,
        .pagination>.active>a:focus,
        .pagination>.active>a:hover,
        .pagination>.active>span,
        .pagination>.active>span:focus,
        .pagination>.active>span:hover {
            border-color: #f7a591;
            background-color: #f7a591;
        }
    </style>
</head>

<body>
    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle show pull-left" data-target="sidebar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false"
                    aria-controls="navbar">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="index.html">首页</a>
            </div>
            <div id="navbar" class="collapse navbar-collapse">
                <ul class="nav navbar-nav">
                    <li>
                        <a href="coupon-apply.html">免费券代申请</a>
                    </li>
                    <li>
                        <a href="coupon-review.html">免费券审批</a>
                    </li>
                </ul>
                <ul class="nav navbar-nav navbar-right">
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
                            <i class="fa fa-user fa-fw"></i>
                            <span class="username"></span>
                            <span class="caret"></span>
                        </a>
                        <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                            <a class="dropdown-item" href="javascript:logout();">退出登录</a>
                        </div>
                    </li>
                </ul>
            </div>
        </div>
    </nav>
    <div class="container-fluid all">
        <div class="sidebar">
            <ul class="nav">
                <li>
                    <a href="index.html">首页</a>
                </li>
                <li class="has-sub">
                    <a href="coupon-review.html">
                        <span>民生免费券</span>
                        <i class="fa fa-caret-right fa-fw pull-right"></i>
                    </a>
                </li>
                <li class="has-sub">
                    <a href="add-sample/sample-list.jsp">
                        <span>送检单</span>
                        <i class="fa fa-caret-right fa-fw pull-right"></i>
                    </a>
                </li>
                <li class="has-sub">
                    <a href="report-review.html">
                        <span>检测报告查询</span>
                        <i class="fa fa-caret-right fa-fw pull-right"></i>
                    </a>
                </li>
                <li class="has-sub">
                    <a href="samplebase_send.html">
                        <span>送检单数据传送</span>
                        <i class="fa fa-caret-right fa-fw pull-right"></i>
                    </a>
                </li>
            </ul>
        </div>
        <div class="maincontent">
            <!--我是主要内容-->
            <div class="panel panel-default">
                <div class="panel-heading">
                    查询条件
                </div>
                <div class="panel-body form-group" style="margin-bottom:0px; position:relative;">
                    <div class="params-warpper">
                        <div class="params-item">
                            <label class="control-label">送检单号：</label>
                            <input type="text" placeholder="请输入送检单号" class="form-control value" id="search-no" />
                        </div>
                        <div class="params-item">
                            <label class="control-label">开始日期：</label>
                            <input type="date" class="form-control value" id="search-start-time" />
                        </div>
                        <div class="params-item">
                            <label class="control-label">状态：</label>
                            <select type="text" class="form-control value" id="search-status">
                                <option value=''>请选择状态</option>
                                <option value="200">已送检</option>
                                <option value="400">接收正常</option>
                                <option value="500">接收异常</option>
                            </select>
                        </div>
                    </div>
                    <div class="params-warpper">
                        <div class="params-item">
                            <label class="control-label">送检医生：</label>
                            <input type="text" placeholder="请输入送检医生姓名" class="form-control value" id="search-doctor" />
                        </div>
                        <div class="params-item">
                            <label class="control-label">结束时间：</label>
                            <input type="date" class="form-control value" id="search-end-time" />
                        </div>
                        <div class="params-item">
                            <label class="control-label">送检医院：</label>
                            <input type="text" placeholder="送检医院" class="form-control value" id="search-hospital" />
                        </div>
                    </div>
                    <button class="btn btn-primary" id="search-btn">查询</button>
                </div>
            </div>
            <table id="mytab" class="table table-hover"></table>
            <div id="toolbar" class="btn-group pull-right" style="margin-right: 20px;">
                <button id="btn_batch_send" type="button" class="btn btn-default" style="display: block; border-radius: 0">
                    <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>批量发送
                </button>
            </div>
        </div>
    </div>
    <a href="#top" id="goTop">
        <i class="fa fa-angle-up fa-3x"></i>
    </a>



    <script>

        //退出登录
        function logout() {
            $.ajax({
                url: '/csfy/dologout.do',
                method: 'POST',
                success: function (res) {
                    if (JSON.parse(res).code == 200) {
                        window.location.href = "/csfy/index.do"
                    }
                }
            })
        }
        //TODO 获取当前登录用户所在的省市区 start
        //设置街道
        function onSteetChange(parentId) {
            town = $("#steetSelect option[value='" + parentId + "']").text();
        }
        //设置地区
        function onCountryChange(parentId) {
            country = $("#countrySelect option[value='" + parentId + "']").text();
            $.ajax({
                method: 'POST',
                url: '/csfy/intf.do',
                data: {
                    method: 'getAddrs',
                    parentId,
                },
                success: (res) => {
                    if (res.code == 200 && res.rows) {
                        var steetList = '';
                        town = '';
                        res.rows.map((item, index) => {
                            if (index == 0) {
                                town = item.name;
                            }
                            steetList += '<option value="' + item.code + '">' + item.name + '</option>'
                        })
                        $("#steetSelect").html(steetList);
                    }
                }
            });
        }

        Date.prototype.pattern = function (fmt) {
            var o = {
                "M+": this.getMonth() + 1, //月份
                "d+": this.getDate(), //日
                "h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, //小时
                "H+": this.getHours(), //小时
                "m+": this.getMinutes(), //分
                "s+": this.getSeconds(), //秒
                "q+": Math.floor((this.getMonth() + 3) / 3), //季度
                "S": this.getMilliseconds() //毫秒
            };
            var week = {
                "0": "/u65e5",
                "1": "/u4e00",
                "2": "/u4e8c",
                "3": "/u4e09",
                "4": "/u56db",
                "5": "/u4e94",
                "6": "/u516d"
            };
            if (/(y+)/.test(fmt)) {
                fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
            }
            if (/(E+)/.test(fmt)) {
                fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "/u661f/u671f" : "/u5468") : '') + week[this.getDay() + '']);
            }
            for (var k in o) {
                if (new RegExp("(" + k + ")").test(fmt)) {
                    fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(('' + o[k]).length)));
                }
            }
            return fmt;
        }
        //根据窗口调整表格高度
        $(window).resize(function () {
            $('#mytab').bootstrapTable('resetView', {
                height: tableHeight()
            })
        })

        //生成用户数据
        $('#mytab').bootstrapTable({
            method: 'POST',
            contentType: "application/x-www-form-urlencoded",//必须要有！！！！
            url: "/ws/getSampleBaseList.do",//要请求数据的文件路径
            height: tableHeight(),//高度调整
            toolbar: '#toolbar',//指定工具栏
            striped: true, //是否显示行间隔色
            dataField: "rows",//bootstrap table 可以前端分页也可以后端分页，这里
            //我们使用的是后端分页，后端分页时需返回含有total：总记录数,这个键值好像是固定的
            //rows： 记录集合 键值可以修改  dataField 自己定义成自己想要的就好
            pageNumber: 1, //初始化加载第一页，默认第一页
            pagination: true,//是否分页
            queryParamsType: 'limit',//查询参数组织方式
            queryParams: queryParams,//请求服务器时所传的参数
            sidePagination: 'server',//指定服务器端分页
            pageSize: 5,//单页记录数
            pageList: [5, 10, 20, 30],//分页步进值
            showRefresh: true,//刷新按钮
            // showColumns: true,
            checkOnSelect : 'true',// 多选框
            clickToSelect: true,//是否启用点击选中行
            toolbarAlign: 'left', //工具栏对齐方式
            buttonsAlign: 'left',//按钮对齐方式
            columns: [
                {
                    title: '全选',
                    field: 'select',
                    //复选框
                    checkbox: true,
                    width: 25,
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '送检医院',
                    field: 'sendHospitalName',
                    align:'center'
                },
                {
                    title: '送检医生',
                    field: 'doctorName',
                    width : 150,
                    align:'center'
                },
                {
                    title: '送检日期',
                    field: 'sendDate',
                    //列数据格式化
                    formatter: formatDate,
                    width : 100,
                    align:'center'
                },
                {
                    title: '送检时间',
                    field: 'sendTime',
                    //列数据格式化
                    //formatter: formatTime
                    width : 100,
                    align:'center'
                },
                {
                    title: '送检医生电话',
                    field: 'doctorPhoneNum',
                    width : 100,
                    align:'center'
                },
                {
                    title: '推送次数',
                    field: 'count',
                    //列数据格式化
                    width: 100,
                    align:'center'
                },
                {
                    title: '状态',
                    field: 'isGet',
                    //列数据格式化
                    formatter: formatStatus,
                    width : 150,
                    align:'center'
                },
                {
                    title: '操作',
                    field: 'Attribute',
                    align: 'center',
                    //列数据格式化
                    formatter: operateFormatter,
                    width : 100,
                    align:'center'
                }
            ],
            locale: 'zh-CN',//中文支持,
            responseHandler: function (res) {
                //在ajax获取到数据，渲染表格之前，修改数据源
                return res;
            },
            onRefresh: function (params) {
                if (params && params.query) {
                    //alert(1123);
                    return false;
                }
                $("#search-no").val('');
                $("#search-start-time").val('');
                $("#search-end-time").val('');
                $("#search-status").val('');
                $("#search-doctor").val('');
                $("#search-hospital").val('');
            }
        });

        //三个参数，value代表该列的值
        function formatStatus(value, row, index) {

            var text = ''
            if (value == 1) {
                text = '审批通过';
            } else if (value == 0) {
                text = '审批中';
            } else if (value == -1) {
                text = '未审批通过';
            } else if (value == 2) {
                text = '已使用';
            } else if (value == 3) {
                text = '已绑定';
            }
            return `<span style="color: rgba(0,0,0,.45);">${text}</span>`;
        }

        //三个参数，value代表该列的值
        function operateFormatter(value, row, index) {
            return '<a href="javascript:getInfo(' + ('\'' + row.id + '\'') + ');">接收</a>&nbsp;&nbsp;&nbsp;<a href="javascript:sendInfo(' + ('\'' + row.id + '\'') + ');">发送</a>';
        }

        function setIdCard(id) {
            idCard = id;
            $('#myModal').modal('show')
        }

        //三个参数，value代表该列的值
        function formatDate(value, row, index) {
            var time = Date.parse(value);
            var date = new Date(time);
            return date.pattern("yyyy-MM-dd")
        }

        //请求服务数据时所传参数
        function queryParams(params) {

            return {
                //每页多少条数据
                rows: params.limit,
                //请求第几页
                page: (params.offset + params.limit) / params.limit,
            }
        }

        //查询按钮事件
        $('#search-btn').click(function () {

            var sampleBaseId = $("#search-no").val() || '';
            var startTime = $("#search-start-time").val() || '';
            var endTime = $("#search-end-time").val() || '';
            var status = $("#search-status").val() || '';
            var doctor = $("#search-doctor").val() || '';
            var hospital = $("#search-hospital").val() || '';

            var query = {};

            if (sampleBaseId != '') {
                query.sampleBaseId = sampleBaseId;
            }
            //开始时间
            if (startTime != '') {
                query.startTime = startTime;
            }
            // 结束时间
            if (endTime != '') {
                query.endTime = endTime;
            }
            if (status != '') {
                query.isGet = status;
            }
            // 送检医院
            if (hospital != '') {
                query.sendHospitalName = hospital;
            }
            // 送检医生
            if (doctor != '') {
                query.doctorName = doctor;
            }
            $('#mytab').bootstrapTable('refresh', {url: '/ws/getSampleBaseList.do', query});
        })
        //tableHeight函数
        function tableHeight() {
            //可以根据自己页面情况进行调整
            return $(window).height() - 280;
        }

        $("#btn_batch_send").click(function () {
            alert("批量发送研发中...");
        });

    </script>
</body>

</html>